"""Core dependencies for FastAPI app."""

from motor.motor_asyncio import AsyncIOMotorClient
import redis.asyncio as redis
from .config import settings

# MongoDB client instance
_mongodb_client = None

# Redis client instance  
_redis_client = None


async def get_mongodb_client() -> AsyncIOMotorClient:
    """Get MongoDB client instance."""
    global _mongodb_client
    if _mongodb_client is None:
        _mongodb_client = AsyncIOMotorClient(settings.mongodb_url)
    return _mongodb_client


async def get_redis_client():
    """Get Redis client instance."""
    global _redis_client
    if _redis_client is None:
        _redis_client = await redis.from_url(
            settings.redis_url,
            encoding="utf-8",
            decode_responses=True
        )
    return _redis_client


async def get_current_user():
    """获取当前用户（临时实现）"""
    return {"user_id": "test_user", "username": "test"}